package com.jrx.anytxn.transaction.job.interestFile.step;

import com.jrx.anytxn.transaction.config.InterestFileConfig;
import com.jrx.anytxn.transaction.constant.TransBizConstant;
import com.jrx.anytxn.transaction.service.IInterestFileService;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.batch.item.ItemWriter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class InterFileWriter implements ItemWriter<String> {

    @Autowired
    private IInterestFileService interestFileService;

    @Autowired
    private InterestFileConfig interestFileConfig;

    @Override
    public void write(List<? extends String> items) throws Exception {
        if(CollectionUtils.isNotEmpty(items)){
            interestFileService.generatingFile((List<String>) items,interestFileConfig.getInterestFilePath(),
                    interestFileConfig.getInterestFileName(), TransBizConstant.FILE_NAME_INTER);
        }
    }
}
